<?php

namespace app\export;

class OrdersExport
{

    protected array $headings = [
        'id'=>'ID',
        'shop_name'=>'店铺代码',
        'name'=>'草稿编号',
        'last_order_name'=>'订单编号',
        'transaction_id'=>'交易号',
        'total_price'=>'金额',
        'repurchase_price'=>'加购金额',
        'pay_method'=>'支付方式',
        'order_status_name'=>'支付状态',
        'created_at'=>'时间-CN',
        'created_date'=>'时间-US',
        'contact_email'=>'客户邮箱',
    ];

    public function __construct(protected array $data)
    {
    }

    public function toArray() :array
    {
        if(!$this->data) return [];
        $array = [];
        $keys = array_keys($this->headings);
        foreach ($keys as $key){
            foreach ($this->data as $data){
                if(array_key_exists($key,$data)){
                    $array[] = $data[$key];
                }
            }
        }
        return $array;

    }

    public function getHeadings():array
    {
        return $this->headings;
    }



}